{% extends 'bbs/base.html' %}
{% block title %}
    首页-青灯论坛
{% endblock %}

{% block main %}
    <div class="articles">
    {% for article in paginate.items %}
        <div class="layui-card article">
            <div class="layui-card-header">
                <a href="/article/{{ article.id }}" class="news_pic">
                    <img src="{{ article.index_image_url }}">
                </a>
            </div>
            <div class="layui-card-body">
                <a href="/article/{{ article.id }}" class="news_title">{{ article.title }}</a>
                <a href="/article/{{ article.id }}" class="news_detail">{{ article.digest }}</a>
                <div class="author_info">
                    <div class="author">
                        <img src="/static/images/person.png" alt="author">
                        <a href="#">陶建辉(Jeff)</a>
                    </div>
                    <div class="time">{{ article.create_time }}</div>
                </div>
            </div>
        </div>
    {% endfor %}
    </div>
{% endblock %}

<div class="layui-footer footer">
    <div class="footer_links">
        <a href="">关于我们</a>
        <span>|</span>
        <a href="">联系我们</a>
        <span>|</span>
        <a href="">招聘人才</a>
        <span>|</span>
        <a href="">友情链接</a>
    </div>
    <p class="copyright">
        CopyRight © 2020 湖南青灯教育科技有限公司 All Rights Reserved<br>
        电话：010-****888 京ICP备*******8号
    </p>
</div>
{% block foot_block %}
    <script src="/static/layui/layui.js"></script>
    {#<script src="/static/js/main.js"></script>#}
    {#<script src="/static/js/bbs/index.js"></script>#}
    <script>
      layui.use('laypage', function() {
        var laypage = layui.laypage;
        laypage.render({
          elem: 'pagination',
          count: {{ paginate.total }},
          curr: {{ paginate.page }},
          limit: {{ paginate.per_page }},
          first: '首页',
          last: '尾页',
          jump: function(obj, first) {
            console.log(obj.curr);
            // 更改url进行跳转

            if (!first) {
              let search = new URLSearchParams(location.search);
              searchParams.set('page', obj.curr);
              location.search = searchParams.toString();
            }
          },
        });
      });
    </script>
{% endblock %}
